# -*- coding: utf-8 -*-#
#-------------------------------------------------------------------------------
# 建立者:        Young  
# Name:         demo9.05
# Description:
# Author:       $赵怡蕾
# Date:         2019/3/5
#-------------------------------------------------------------------------------

# 第1个自定义异常类
class CustomException1(Exception):
    pass
# 第2个自定义异常类
class CustomException2(Exception):
    pass
# 第3个自定义异常类
class CustomException3(Exception):
    pass
# 导入random模块
import random

# 随机抛出前面3个自定义异常
def raiseException():
    n = random.randint(1,3)                       # 随机参数1到3的随机整数
    print("抛出CustomException{}异常".format(n))
    if n == 1:
        raise CustomException1                    # 抛出CustomException1
    elif n == 2:
        raise CustomException2                    # 抛出CustomException2
    else:
        raise CustomException3                    # 抛出CustomException3

try:
    raiseException()                              # 随机抛出3个异常
# 使用except子句同时捕捉这3个异常
except (CustomException1,CustomException2,CustomException3):
    print("******执行异常处理程序******")